
let navigateTo = {}

/**
 * 静态路径跳转
 * @param {string} pagesName   路径静态名称(必传项)：lib/static.js 
 * @param {string} parmas     参数(选传项)
 */
navigateTo.baseUrl = function (baseurl = '') {
    if (Object.prototype.toString.call(baseurl) != "[object String]" || !baseurl) {
        return { state: false, msg: '跳转链接错误或缺失' }
    }
    my.navigateToOutside({
        url: baseurl,
        success: () => {
            $global.mfutil.logger.log('baseUrl跳转 成功', 'baseUrl');
            return { state: true, msg: 'baseUrl跳转: ' + baseurl + '成功' }
        },
        fail: (err) => {
            $global.mfutil.logger.log('baseUrl跳转 失败', 'baseUrl');
            return { state: false, msg: 'baseUrl跳转: ' + baseurl + '失败' + JSON.stringify(err) }
        },
        complete: () => {
            $global.mfutil.logger.log('baseUrl跳转 结束', 'baseUrl');
            return { state: false, msg: 'baseUrl跳转: ' + baseurl + '结束' }
        }
    })
}
navigateTo.jumpHandle = function (jumpUrl) {
    if (!jumpUrl || Object.prototype.toString.call(jumpUrl) != "[object String]") return
    jumpUrl = jumpUrl.trim()
    let expresult = expUrl(jumpUrl)
    if (expresult) {
        navigateTo.baseUrl(jumpUrl)
        $global.mfutil.logger.log(jumpUrl, 'jumpHandle1');
    } else {
        navigateTo.baseUrl(encodeURI($global.appletsJumpLink + '&' + jumpUrl))
        $global.mfutil.logger.log(encodeURI($global.appletsJumpLink + '&' + jumpUrl), 'jumpHandle2');
    }

}
const expUrl = function (URL) {
    var Expression = /^http(s)?:\/\//;
    var objExp = new RegExp(Expression);
    return objExp.test(URL)
}

export default { ...navigateTo }